def isPrime(number)
    if number <= 1
        return false
    elsif number == 2
        return true
    else
        (2..Math.sqrt(number).floor).each do |divisor|
            if number.modulo(divisor) == 0
                return false
            end
        end

    end
    true
end

def primeFactors(number)
    primeFactors = []
    (2..number / 2).each do |counter|
        if isPrime(counter) && number.modulo(counter) == 0
            primeFactors.push counter
        end
    end
    primeFactors
end

numbers = []
howMany = 3
counter = 4
while numbers.length < howMany
    primeFactors = primeFactors counter
    if primeFactors.length == howMany
        puts counter
        numbers.push counter
        yes = true
        (1..howMany - 1).each do |number|
            nextNumber = counter + number
            if primeFactors(nextNumber).length != howMany
                yes = false
                break
            else
                numbers.push nextNumber
            end
        end
        if !yes
            numbers.clear
        end
    end
    counter = counter + 1
end

puts numbers